﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;
using ApiBetaSeries.Utils;

namespace ApiBetaSeries.Model
{
    /// <summary>
    /// Represent a subtitle
    /// </summary>
    internal class Subtitle : ApiBetaSeries.ISubtitle
    {

        /// <summary>
        /// Empty constructor
        /// </summary>
        public Subtitle() { }

        #region Attributes
        /// <summary>
        /// Show of the subtitle
        /// </summary>
        public string Show { get; set; }
        /// <summary>
        /// number of the season of the episode
        /// </summary>
        public int Season { get; set; }
        /// <summary>
        /// number of the episode
        /// </summary>
        public int Episode { get; set; }
        /// <summary>
        /// language of the episode
        /// </summary>
        public SubtitleLanguage Language { get; set; }
        /// <summary>
        /// source of the subtitle (addic7ed, seriessub, soutitres, tvsubititles, usub)
        /// </summary>
        public string Source { get; set; }
        /// <summary>
        /// name of the file of the subtitle
        /// </summary>
        public string FileName { get; set; }
        /// <summary>
        /// url to the subtitle
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// Quality of the subtitle
        /// </summary>
        public int Quality { get; set; }

        #endregion Attributes
        #region Inherits
        public override bool Equals(object obj)
        {
            if (obj == null) return false;
            
            if (this.GetType() != obj.GetType()) return false;
            
            Subtitle sub = (Subtitle) obj;
            if (!Object.Equals(this.Show, sub.Show)) return false;
            if (!Object.Equals(this.Season, sub.Season)) return false;
            if (!Object.Equals(this.Episode, sub.Episode)) return false;
            if (!Object.Equals(this.Language, sub.Language)) return false;
            if (!Object.Equals(this.Source, sub.Source)) return false;
            if (!Object.Equals(this.FileName, sub.FileName)) return false;
            if (!Object.Equals(this.Url, sub.Url)) return false;
            if (!Object.Equals(this.Quality, sub.Quality)) return false;

            // If we're here : everything's the same
            return true;
        }

        public override int GetHashCode()
        {
            return Show.GetHashCode() ^ Season.GetHashCode() ^ Episode.GetHashCode() ^ FileName.GetHashCode() ^ Url.GetHashCode();
        }

        public override string ToString()
        {
            return FileName;
        }
        #endregion Inherits

    }
}
